package com.guanzi.server.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 公共返回对象
 * @author Xg
 * @date 2021/6/3 10:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean {

    private Integer code;
    private String msg;
    private Object obj;

    /**
     * 成功返回信息
     * @param msg
     * @return
     */
    public static RespBean success(String msg){
        return new RespBean(200, msg, null);
    }

    /**
     * 成功返回对象和信息
     * @param msg
     * @param obj
     * @return
     */
    public static RespBean success(String msg, Object obj){
        return new RespBean(200, msg, obj);
    }

    /**
     * 失败返回信息
     * @param msg
     * @return
     */
    public static RespBean error(String msg){
        return new RespBean(500, msg, null);
    }

    /**
     * 失败返回对象和信息
     * @param msg
     * @param obj
     * @return
     */
    public static RespBean error(String msg, Object obj){
        return new RespBean(500, msg, obj);
    }

}
